package com.doublefish.doublefishrobot.utils.db.database.bean;

import java.util.List;
import java.util.Map;

/**
 * 作者:dugaofeng on 2024/10/16 14:41
 */
public class SQLiteResult  {

    private boolean mIsSuccess;             //是否成功
    private int mCount = 0;                     //获取数据条目数
    private String mErrorMsg = null;               //错误信息
    private Map<String,Object> mData = null;        //查找到的第一条数据
    private List<Map<String,Object>> mList = null;  //查找到是所有数据

    private SQLiteResult() {}

    public SQLiteResult(boolean isSuccess) {
        this.mIsSuccess = isSuccess;
    }

    public SQLiteResult(boolean isSuccess, String errorMsg) {
        this.mIsSuccess = isSuccess;
        this.mErrorMsg = errorMsg;
    }

    public SQLiteResult(boolean isSuccess, int count) {
        this.mIsSuccess = isSuccess;
        this.mCount = count;
    }

    public SQLiteResult(boolean isSuccess,Map<String,Object> data,List<Map<String,Object>> list) {
        this.mIsSuccess = isSuccess;
        this.mData = data;
        this.mList = list;
    }

    public SQLiteResult(boolean isSuccess,int count,Map<String,Object> data,List<Map<String,Object>> list) {
        this.mIsSuccess = isSuccess;
        this.mCount = count;
        this.mData = data;
        this.mList = list;
    }


    public boolean isSuccess() {
        return mIsSuccess;
    }

    public void setCount(int mCount) {
        this.mCount = mCount;
    }

    public int getCount() {
        return mCount;
    }

    public void setErrorMsg(String mErrorMsg) {
        this.mErrorMsg = mErrorMsg;
    }

    public String getErrorMsg() {
        return mErrorMsg;
    }

    public void setData(Map<String, Object> mData) {
        this.mData = mData;
    }

    public Map<String, Object> getData() {
        return mData;
    }

    public void setList(List<Map<String, Object>> mList) {
        this.mList = mList;
    }

    public List<Map<String, Object>> getList() {
        return mList;
    }


    /******** 部分固定的数据库结果 *********/

    //sql语句执行成功
    public static SQLiteResult SqlExecuteSuccess() {
        return new SQLiteResult(true);
    }

    //错误类型 SqLiteDatabaseIsNull
    public static SQLiteResult SqLiteDatabaseIsNull() {
        return new SQLiteResult(false,SQLiteTips.SqLiteDatabaseIsNull);
    }

    //错误类型 SqLiteDatabaseHelperIsNull
    public static SQLiteResult SqLiteDatabaseHelperIsNull() {
        return new SQLiteResult(false,SQLiteTips.SqLiteDatabaseHelperIsNull);
    }

    //错误类型 SqLiteDatabaseCursorIsNull
    public static SQLiteResult SqLiteDatabaseCursorIsNull() {
        return new SQLiteResult(false,SQLiteTips.SqLiteDatabaseCursorIsNull);
    }

    //错误类型 SqlSentenceErroe  sql语句错误
    public static SQLiteResult SqlSentenceError() {
        return new SQLiteResult(false,SQLiteTips.SqlSentenceError);
    }

    //错误类型 TableNameError  表名错误
    public static SQLiteResult TableNameError() {
        return new SQLiteResult(false,SQLiteTips.TableNameError);
    }

    //错误类型 SqlInsertDataIsNull  插入数据错误
    public static SQLiteResult SqlInsertDataIsNull() {
        return new SQLiteResult(false,SQLiteTips.SqlInsertDataIsNull);
    }
}